Sleepy Test ^^^^^ **Definition:** * Developers introduce this smell when they need to pause execution of statements in a test method for a certain duration (i.e., simulate an external event) and then continuing with execution. Explicitly causing a thread to sleep can lead to unexpected results as the processing time for a task differs when executed in various environments and configurations. **Code Example:** .. code-block:: java public void testEdictExternSearch() throws Exception { final Intent i = new Intent(getInstrumentation().getContext(), ResultActivity.class); i.setAction(ResultActivity.EDICT_ACTION_INTERCEPT); i.putExtra(ResultActivity.EDICT_INTENTKEY_KANJIS, "空白"); tester.startActivity(i); assertTrue(tester.getText(R.id.textSelectedDictionary).contains("Default")); final ListView lv = getActivity().getListView(); assertEquals(1, lv.getCount()); DictEntry entry = (DictEntry) lv.getItemAtPosition(0); assertEquals("Searching", entry.english); Thread.sleep(500); final Intent i2 = getStartedActivityIntent(); final List result = (List) i2.getSerializableExtra(ResultActivity.INTENTKEY_RESULT_LIST); entry = result.get(0); assertEquals("(adj-na,n,adj-no) blank space/vacuum/space/null (NUL)/(P)", entry.english); assertEquals("空白", entry.getJapanese()); assertEquals("くうはく", entry.reading); assertEquals(1, result.size()); } **References:** .. admonition:: Quality attributes * :octicon:`file-code;1em` - Code Example * :octicon:`comment-discussion;1em` - Cause and Effect * :octicon:`graph;1em` - Frequency * :octicon:`sync;1em` - Refactoring * `An Exploratory Study on the Refactoring of Unit Test Files in Android Applications `_ :octicon:`comment-discussion;1em` :octicon:`sync;1em` * `Automatic Identification of High-Impact Bug Report by Product and Test Code Quality `_ * `Automatic generation of smell-free unit tests `_ :octicon:`comment-discussion;1em` * `Characterizing High-Quality Test Methods: A First Empirical Study `_ :octicon:`graph;1em` * `Handling Test Smells in Python: Results from a Mixed-Method Study `_ * `Investigating Severity Thresholds for Test Smells `_ :octicon:`comment-discussion;1em` * `Investigating Test Smells in JavaScript Test Code `_ :octicon:`graph;1em` * `On the Distribution of "Simple Stupid Bugs" in Unit Test Files: An Exploratory Study `_ * `On the diffusion of test smells and their relationship with test code quality of Java projects `_ :octicon:`graph;1em` * `On the distribution of test smells in open source Android applications: an exploratory study `_ :octicon:`file-code;1em` :octicon:`graph;1em` * `On the influence of Test Smells on Test Coverage `_ * `On the test smells detection: an empirical study on the jnose test accuracy `_ :octicon:`graph;1em` * `On the use of test smells for prediction of flaky tests `_ :octicon:`comment-discussion;1em` :octicon:`graph;1em` * `PyNose: A Test Smell Detector For Python `_ :octicon:`comment-discussion;1em` :octicon:`graph;1em` * `Pytest-Smell: a smell detection tool for Python unit tests `_ :octicon:`graph;1em` * `Software Unit Test Smells `_ :octicon:`file-code;1em` * `TEMPY: Test Smell Detector for Python `_ :octicon:`graph;1em` * `Test Smell Detection Tools: A Systematic Mapping Study `_ * `The secret life of test smells-an empirical study on test smell evolution and maintenance `_ :octicon:`graph;1em` * `Understanding practitioners’ strategies to handle test smells: a multi-method study `_ :octicon:`comment-discussion;1em` :octicon:`sync;1em` * `What the Smell? An Empirical Investigation on the Distribution and Severity of Test Smells in Open Source Android Applications `_ :octicon:`file-code;1em` :octicon:`graph;1em` * `tsDetect: an open source test smells detection tool `_